package com.wave.olap;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class OlapCriteria<K> {
	protected ArrayList<K> measures;
	protected ArrayList<K> order;
	protected Map<K, List<K>> criteria;
	
	public OlapCriteria(K measure) {
		measures = new ArrayList<K>();
		measures.add(measure);
		order = new ArrayList<K>();
		criteria = new HashMap<K, List<K>>();
	}
	
	public OlapCriteria<K> addOrder(K dimension) {
		if (order == null)
			order = new ArrayList<K>();
		order.add(dimension);
		return this;
	}
	
	public List<K> getOrder() {
		return order;
	}
	
	public Map<K, List<K>> getCriteria() {
		return criteria;
	}
	
	public void addCriteria(K dimension, List<K> criteria) {
		this.criteria.put(dimension, criteria);
	}
	
	public void addCriteria(K dimension, K[] criteria) {
		List<K> list = new ArrayList<K>(Arrays.asList((K[])criteria));
		this.criteria.put(dimension, list);
	}
	
	public void addCriteria(K dimension, K criteria) {
		if (this.criteria.get(dimension) == null)
			this.criteria.put(dimension, new ArrayList<K>());
		this.criteria.get(dimension).add(criteria);
	}
	
	//public abstract void addCriteria(K dimension, List<K> criteria);
	
	public void addFixed(String dimension) {} //defaults to top 
	public void addFixed(String dimension, Integer id) {}
	public void addChildren(String dimension, Integer id) {}
	public void addSiblings(String dimension, Integer id) {}
	public void addParent(String dimension, Integer id) {}
	
	//public abstract OracleOlapBean query();
	
}